<template>
<div class="">
    <div class="pr10">
        <div class="analyItem">
            <p class="analyItemTit tx-center">状态</p>
            <div class="analyItemCon">
            </div>
        </div>
    </div>
    <div class="thinScroll pr10" v-scrollHeight="84">
          <router-link tag="div" exact :to="{path:routerPath('threeePresentKao'),query:{pressIndex: 1, stageInfo: this.stageInfo}}" class=" analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center" :class="userInfoPhoto[51] === undefined || userInfoPhoto[51] === '' || userInfoPhoto[51] === null ||
                    (stageInfo.represent_acreage === undefined || stageInfo.represent_acreage === '' || stageInfo.represent_acreage === null) ||
                    (stageInfo.represent_type === undefined || stageInfo.represent_type === '' || stageInfo.represent_type === null) ||
                    (stageInfo.represent_cost === undefined || stageInfo.represent_cost === '' || stageInfo.represent_cost === null) ||
                    (stageInfo.represent_address === undefined || stageInfo.represent_address === '' || stageInfo.represent_address === null) ||
                    (stageInfo.represent_indeed === undefined || stageInfo.represent_indeed === '' || stageInfo.represent_indeed === null) ? '' : 'analyLightGreen'">案例</p>
            <div class="analyItemCon">
                <!-- <p class="col-md-4">
                    <span>案例</span>
                    <span class="cLightGray pr8">1</span>个
                </p> -->
                <p class="col-md-4">
                    <span>面积</span>
                    <span class="cLightGray pr8">{{stageInfo.represent_acreage ? stageInfo.represent_acreage : ''}}</span>
                </p>
                <p class="col-md-4">
                    <span>类型</span>
                    <span class="cLightGray pr8">{{stageInfo.represent_type ? stageInfo.represent_type : ''}}</span>
                </p>
                <p class="col-md-4">
                    <span>预算</span>
                    <span class="cLightGray pr8">{{stageInfo.represent_cost ? stageInfo.represent_cost : ''}}</span>
                </p>
                <p class="col-md-8">
                    <span>地址</span>
                    <span class="cLightGray pr8">{{stageInfo.represent_address ? stageInfo.represent_address : ''}}</span>
                </p>
                <p class="col-md-4">
                    <span>实地考察</span>
                    <span class="cLightGray pr8">{{stageInfo.represent_indeed==0?'是':'否'}}</span>
                </p>
                <p class="fl">
                    <span v-if="userInfoPhoto[51] === undefined || userInfoPhoto[51] === '' || userInfoPhoto[51] === null ||
                    (stageInfo.represent_acreage === undefined || stageInfo.represent_acreage === '' || stageInfo.represent_acreage === null) ||
                    (stageInfo.represent_type === undefined || stageInfo.represent_type === '' || stageInfo.represent_type === null) ||
                    (stageInfo.represent_cost === undefined || stageInfo.represent_cost === '' || stageInfo.represent_cost === null) ||
                    (stageInfo.represent_address === undefined || stageInfo.represent_address === '' || stageInfo.represent_address === null) ||
                    (stageInfo.represent_indeed === undefined || stageInfo.represent_indeed === '' || stageInfo.represent_indeed === null)" class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">全</span>
                </p>
            </div>
        </router-link>
        <router-link tag="div" exact :to="{path:routerPath('threeDoneKao'), query:{pressIndex: 2, stageInfo: this.stageInfo}}" class=" analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center" :class="this.stageInfo.personnel_management === undefined || this.stageInfo.personnel_management === null || this.stageInfo.personnel_management === '' ||this.stageInfo.personnel_management === 1 ||
            this.stageInfo.site_management === undefined || this.stageInfo.site_management === null || this.stageInfo.site_management === '' || this.stageInfo.site_management === 1 ||
            this.stageInfo.material_management === undefined || this.stageInfo.material_management === null || this.stageInfo.material_management === '' || this.stageInfo.material_management === 1 ||
            this.stageInfo.money_management === undefined || this.stageInfo.money_management === null || this.stageInfo.money_management === '' || this.stageInfo.money_management === 1 ? '' : 'analyLightGreen'">现场管理</p>
            <div class="analyItemCon">
                <p class="col-md-4">
                    <span>管理</span>
                    <span class="cLightGray pr8">{{this.stageInfo.personnel_management === undefined || this.stageInfo.personnel_management === null || this.stageInfo.personnel_management === '' ||this.stageInfo.personnel_management === 1 ||
            this.stageInfo.site_management === undefined || this.stageInfo.site_management === null || this.stageInfo.site_management === '' || this.stageInfo.site_management === 1 ||
            this.stageInfo.material_management === undefined || this.stageInfo.material_management === null || this.stageInfo.material_management === '' || this.stageInfo.material_management === 1 ||
            this.stageInfo.money_management === undefined || this.stageInfo.money_management === null || this.stageInfo.money_management === '' || this.stageInfo.money_management === 1 ? '否' : '是'}} </span>
                </p>
                <!-- <p class="col-md-4">
                    <span>面积</span>
                    <span class="cLightGray pr8">{{stageInfo.make_acreage_start ? stageInfo.make_acreage_start : 0}}-{{stageInfo.make_acreage_end ? stageInfo.make_acreage_end : 0}} 平米</span>
                </p>
                <p class="col-md-4">
                    <span>类型</span>
                    <span class="cLightGray pr8">{{stageInfo.make_type ? stageInfo.make_type : ''}}</span>
                </p> -->
                <p class="fl">
                    <span v-if="this.stageInfo.personnel_management === undefined || this.stageInfo.personnel_management === null || this.stageInfo.personnel_management === '' ||this.stageInfo.personnel_management === 1 ||
            this.stageInfo.site_management === undefined || this.stageInfo.site_management === null || this.stageInfo.site_management === '' || this.stageInfo.site_management === 1 ||
            this.stageInfo.material_management === undefined || this.stageInfo.material_management === null || this.stageInfo.material_management === '' || this.stageInfo.material_management === 1 ||
            this.stageInfo.money_management === undefined || this.stageInfo.money_management === null || this.stageInfo.money_management === '' || this.stageInfo.money_management === 1" class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">全</span>
                </p>
            </div>
        </router-link>
        <!--  加单金额的判断 pmUserInfo.amount === undefined || pmUserInfo.amount === null || pmUserInfo.amount === '' -->
        <router-link tag="div" exact :to="{path:routerPath('threeInspectStrength'), query:{pressIndex: 3, pmUserInfo: this.pmUserInfo}}" class=" analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center" :class="(pmUserInfo.worker_number=== undefined || pmUserInfo.worker_number === '' || pmUserInfo.worker_number === null) ? '' : 'analyLightGreen'">施工实力</p>
            <div class="analyItemCon">
                <p class="col-md-4">
                    <span>标准</span>
                    <span class="cLightGray pr8">10 人</span>
                </p>
                <p class="col-md-4">
                    <span>团队</span>
                    <span class="cLightGray pr8">{{pmUserInfo.worker_number ? pmUserInfo.worker_number : 0}} 人</span>
                </p>
                <!-- <p class="col-md-4">
                    <span>接单金额</span>
                    <span class="cLightGray pr8">{{pmUserInfo.amount ? pmUserInfo.amount : ''}}</span>
                </p> -->
                <p class="fl">
                    <span v-if="(pmUserInfo.worker_number=== undefined || pmUserInfo.worker_number === '' || pmUserInfo.worker_number === null)" class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">全</span>
                </p>
            </div>
        </router-link>
        <router-link tag="div" exact :to="{path:routerPath('threeInspectPonseXing'), query:{pressIndex: 4, stageInfo: this.stageInfo}}" class=" analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center" :class="this.stageInfo.character_type === undefined || this.stageInfo.character_type === null || this.stageInfo.character_type === '' ? '' : 'analyLightGreen'">性格</p>
            <div class="analyItemCon">
                <p class="col-md-1" v-for="item in this.characterList" :key="item">
                    <span>{{item}}</span>
                </p>
                <p class="fl">
                    <span v-if="this.stageInfo.character_type === undefined || this.stageInfo.character_type === null || this.stageInfo.character_type === '' " class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">全</span>
                </p>
            </div>
        </router-link>
        <!--  :class=" this.stageInfo.character_type ? '' : 'analyLightGreen'" -->
        <router-link tag="div" exact :to="{path:routerPath('threeInspectPonsePin'), query:{pressIndex: 5, stageInfo: this.stageInfo}}" class=" analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center" :class="this.stageInfo.character_pin_type === undefined || this.stageInfo.character_pin_type === null || this.stageInfo.character_pin_type === '' ? '' : 'analyLightGreen'">品德</p>
            <div class="analyItemCon">
                <!-- <p class="col-md-12">
                    <span>{{this.characterPinName ? this.characterPinName : ''}}</span>
                </p> -->
                <p class="col-md-2" v-for="item in this.characterPinNameArr" :key="item">
                    <span>{{item}}</span>
                </p>
                <!-- <p class="col-md-4">
                    <span></span>
                    <span class="cLightGray pr8">{{pmUserInfo.amount ? pmUserInfo.amount : ''}}</span>
                </p> -->
                <p class="fl">
                    <span v-if="this.stageInfo.character_pin_type === undefined || this.stageInfo.character_pin_type === null || this.stageInfo.character_pin_type === ''" class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">全</span>
                </p>
            </div>
        </router-link>
        <!-- <router-link tag="div" exact :to="{path:routerPath('threeInspectKao'), query:{pressIndex: 3, stageInfo: this.stageInfo}}" class=" analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center">公司考察</p>
            <div class="analyItemCon">
                <p class="col-md-4">
                    <span>印象</span>
                    <span class="cLightGray pr8">{{stageInfo.investigate_impression ? stageInfo.investigate_impression : ''}}</span>
                </p>
                <p class="col-md-4">
                    <span>认可</span>
                    <span class="cLightGray pr8">{{stageInfo.investigate_approval ? (stageInfo.investigate_approval==0?'是':'否') : ''}}</span>
                </p>
                <p class="fl">
                    <span v-if="(stageInfo.investigate_impression === undefined || stageInfo.investigate_impression === '' || stageInfo.investigate_impression === null) ||
                    (stageInfo.investigate_approval === undefined || stageInfo.investigate_approval === null || stageInfo.investigate_approval === '')" class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">全</span>
                </p>
            </div>
        </router-link> -->
        <!-- <router-link tag="div" exact :to="{path:routerPath('threeJoinKao'),query:{pressIndex: 4, stageInfo: this.stageInfo}}" class=" analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center">加盟意向</p>
            <div class="analyItemCon">
                <p class="col-md-4">
                    <span>加盟费</span>
                    <span class="cLightGray pr8">{{stageInfo.intention_cost ? (stageInfo.intention_cost==0?'是':'否') : ''}}</span>
                </p>
                <p class="col-md-4">
                    <span>提点</span>
                    <span class="cLightGray pr8">{{stageInfo.intention_remind ? (stageInfo.intention_remind==0?'高':'低') : ''}}</span>
                </p>
                <p class="col-md-4">
                    <span>期限</span>
                    <span class="cLightGray pr8">{{stageInfo.intention_term ? (stageInfo.intention_term==0?'是':'否') : ''}}</span>
                </p>
                <p class="col-md-4">
                    <span>意见</span>
                    <span class="cLightGray pr8">{{stageInfo.intention_opinion ? stageInfo.intention_opinion : ''}}</span>
                </p>
                <p class="fl">
                    <span v-if="(stageInfo.intention_cost === undefined || stageInfo.intention_cost === '' || stageInfo.intention_cost === null) ||
                     (stageInfo.intention_remind === undefined || stageInfo.intention_remind === '' || stageInfo.intention_remind === null) ||
                     (stageInfo.intention_term === undefined || stageInfo.intention_term === '' || stageInfo.intention_term === null) ||
                     (stageInfo.intention_opinion === undefined || stageInfo.intention_opinion === '' || stageInfo.intention_opinion === null)" class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">全</span>
                </p>
            </div>
        </router-link> -->
        <router-link tag="div" exact :to="{path:routerPath('threeStandardKao'),query:{pressIndex: 5, standards: this.standards}}" class=" analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center" :class="(Number(this.standards.length) === 0 || this.scores < (30 * this.pmStandardSize)) ? '' : 'analyLightGreen'">解答</p>
            <div class="analyItemCon">
                <p class="col-md-4">总分：<span class="cLightGray pr8">{{ 40 * this.pmStandardSize }}</span></p >
                <p class="col-md-4">得分：<span class="cLightGray pr8">{{ Number(this.standards.length) > 0 ? this.scores : 0 }}</span></p >
                <p class="fl">
                    <span v-if="Number(this.standards.length) === 0 || this.scores < (30 * this.pmStandardSize)" class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">过</span>
                </p>
            </div>
        </router-link>
        <router-link tag="div" exact :to="{path:routerPath('threeIntroduce'),query:{pressIndex: 4}}" class="analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center">介绍</p >
            <div class="analyItemCon">
                <p class="col-md-6">瑞祥介绍</p >
            </div>
        </router-link>

    </div>
     <!-- anItemBor：这个样式是可以边框变蓝 -->
    <div class="analyItem" active-class="anItemBor-active">
        <p class="analyItemTit tx-center">处理</p >
      <div class="analyItemCon tx-center">
          <el-button @click="submit()" v-if="userInfoPhoto[51] === undefined || userInfoPhoto[51] === '' || userInfoPhoto[51] === null ||
                    (stageInfo.represent_acreage === undefined || stageInfo.represent_acreage === '' || stageInfo.represent_acreage === null) ||
                    (stageInfo.represent_type === undefined || stageInfo.represent_type === '' || stageInfo.represent_type === null) ||
                    (stageInfo.represent_cost === undefined || stageInfo.represent_cost === '' || stageInfo.represent_cost === null) ||
                    (stageInfo.represent_address === undefined || stageInfo.represent_address === '' || stageInfo.represent_address === null) ||
                    (stageInfo.represent_indeed === undefined || stageInfo.represent_indeed === '' || stageInfo.represent_indeed === null) ||
                    this.stageInfo.character_type === undefined || this.stageInfo.character_type === null || this.stageInfo.character_type === '' ||
                    this.stageInfo.character_pin_type === undefined || this.stageInfo.character_pin_type === null || this.stageInfo.character_pin_type === '' ||
                    this.stageInfo.personnel_management === undefined || this.stageInfo.personnel_management === null || this.stageInfo.personnel_management === '' || this.stageInfo.personnel_management === 1 ||
                    this.stageInfo.site_management === undefined || this.stageInfo.site_management === null || this.stageInfo.site_management === '' || this.stageInfo.site_management === 1 ||
                    this.stageInfo.material_management === undefined || this.stageInfo.material_management === null || this.stageInfo.material_management === '' || this.stageInfo.material_management === 1 ||
                    this.stageInfo.money_management === undefined || this.stageInfo.money_management === null || this.stageInfo.money_management === '' || this.stageInfo.money_management === 1 ||
                    Number(this.standards.length) === 0 || this.scores < (30 * this.pmStandardSize) ||
                    (pmUserInfo.worker_number=== undefined || pmUserInfo.worker_number === '' || pmUserInfo.worker_number === null)" disabled>通过</el-button>
                    <!-- pmUserInfo.amount === undefined || pmUserInfo.amount === null || pmUserInfo.amount === '' -->
        <el-button @click="submit()" v-else>通过</el-button>
          <!-- <el-button @click="submit()">通过</el-button>  -->
      </div>
     </div>
</div>
</template>
<script>
import { mapGetters, mapMutations } from 'vuex'
import { findStageInfoById, getUserListinfoPhoto, getCharacterList, getPmStandardList, getPmStandardUserList, nextStage, selectPmUserInfoManager } from '../Resources/Api'
export default {
    data () {
        return {
            pmStandardSize: 0, // 该阶段有几个标准
            userInfoPhoto: {},
            pmUserInfo: {},
            representAcreageList: [], // 代表项目照片
            standards: [], // 用户该阶段的得分
            scores: 0, // 得分
            stageInfo: {}, // 用户信息
            make_acreage: 0, // 面积
            characterType: '', // 性格
            characterArr: [],
            characterList: [],
            characterPinArr: [], // 品德的list
            characterPinName: '', // 品德名称
            characterPinNameArr: []
        }
    },
    created () {
        this.findStageInfoById()
        this.getPmStandardUserList()
        // this.findPhotoByUid()
        this.selectPmUserInfoManager()
        this.getPmStandardList()
        // this.getCharacterList()
    },
    methods: {
        ...mapMutations({
            setUpdateLeft: `SET_UPDATE_LEFT`
        }),
        getCharacterList () {
            getCharacterList({
                // type: 2
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    let list = []
                    list = result.data.Body.characters
                    this.characterPinNameArr = []
                    this.characterPinName = ''
                    this.characterPinArr.forEach(characterPin => {
                        let arr = characterPin.split('-')
                        const constIndex = list.findIndex(character => Number(arr[0]) === Number(character.type) && Number(arr[1]) === Number(character.two_type))
                        if (constIndex >= 0) {
                            this.characterPinNameArr.push(list[constIndex].two_key)
                        }
                    })
                    // this.characterPinName = this.characterPinNameArr.join('       ')
                }
            }).catch(err => {
                console.log(err)
            })
        },
        selectPmUserInfoManager () {
            selectPmUserInfoManager({
                uid: this.leftInfo.uid// this.leftInfo.uid //this.leftInfo.uid //
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    this.pmUserInfo = result.data.Body
                }
            }).catch(err => {
                console.log(err)
            })
        },
        // 获取照片信息
        UerInfoPhotoFn () {
            getUserListinfoPhoto({
                uid: this.leftInfo.uid // this.leftInfo.uid
            }).then(result => {
                if (result.data.StatusCode === 0) {
                    this.userInfoPhoto = result.data.Body
                }
            }).catch(err => {
                console.log(err)
            })
        },
        submit () {
            nextStage({
                userId: this.leftInfo.uid
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    layer.msg('提交成功')
                    this.setUpdateLeft()
                }
            }).catch(err => {
                console.log('进入下一阶段失败nextStage,异常信息：' + err)
            })
        },
        // 查询指定阶段的所有标准
        getPmStandardList () {
            getPmStandardList({
                stId: 3 // 认知阶段
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    this.pmStandardSize = result.data.Body.pmStandards.length
                }
            }).catch(err => {
                console.log('查询指定阶段的所有标准失败getPmStandardList，异常信息：' + err)
            })
        },
        // 查询用户成绩
        getPmStandardUserList () {
            getPmStandardUserList({
                stId: 3, // 阶段id 1-咨询，2-认知，3-考察，4-签约
                uid: this.leftInfo.uid
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    this.standards = result.data.Body.pmStandardUsers
                    // console.log(this.stageInfo)
                    if (this.standards.length > 0) {
                        //
                        this.standards.forEach(standard => {
                            //
                            const sdScore = Number(standard.sd_score)
                            if (sdScore === 1) {
                                this.scores += 40
                            } else if (sdScore === 2) {
                                this.scores += 30
                            } else if (sdScore === 3) {
                                this.scores += 20
                            } else if (sdScore === 4) {
                                this.scores += 10
                            }
                        })
                    }
                }
            }).catch(err => {
                console.log('查询用户成绩失败getPmStandardUserList，异常信息：' + err)
            })
        },
        // 获取所有信息
        findStageInfoById () {
            findStageInfoById({
                uid: this.leftInfo.uid
            }).then(result => {
                this.stageInfo = result.data.Body
                if (this.stageInfo.character_type !== undefined && this.stageInfo.character_type !== null && this.stageInfo.character_type !== '') {
                    this.characterArr = this.stageInfo.character_type.split(',')
                    this.characterList = []
                    this.characterArr.forEach(character => {
                        let arr = character.split('-')
                        if (Number(arr[0]) === 1) {
                            if (Number(arr[1]) === 1) {
                                this.characterList.push('开朗')
                            } else {
                                this.characterList.push('谨慎')
                            }
                        } else if (Number(arr[0]) === 2) {
                            if (Number(arr[1]) === 1) {
                                this.characterList.push('感性')
                            } else {
                                this.characterList.push('理性')
                            }
                        } else if (Number(arr[0]) === 3) {
                            if (Number(arr[1]) === 1) {
                                this.characterList.push('敏感')
                            } else {
                                this.characterList.push('随和')
                            }
                        } else if (Number(arr[0]) === 4) {
                            if (Number(arr[1]) === 1) {
                                this.characterList.push('细致')
                            } else {
                                this.characterList.push('粗糙')
                            }
                        } else if (Number(arr[0]) === 5) {
                            if (Number(arr[1]) === 1) {
                                this.characterList.push('活泼')
                            } else {
                                this.characterList.push('稳重')
                            }
                        }
                        // console.log(this.characterList)
                    })
                }

                this.characterPinArr = []
                if (this.stageInfo.character_pin_type !== undefined && this.stageInfo.character_pin_type !== null && this.stageInfo.character_pin_type !== '') {
                    this.characterPinArr = this.stageInfo.character_pin_type.split(',')
                    this.getCharacterList()
                }
            }).catch(err => {
                console.log(err)
            })
        },
        // 点击通过
        commit () {
            this.$emit('listenToChildEvent', '签约')
        },
        // 路由跳转路径拼接
        routerPath (path) {
            return this.$route.matched[1].path + '/' + path
        },
        // 直接进行路由跳转路径
        routerPush (path) {
            this.$router.push(this.$route.matched[1].path + '/' + path)
        }
    },
    computed: {
        ...mapGetters(['leftInfo', 'updatePlate'])
    },
    watch: {
        updatePlate () {
            this.scores = 0
            this.getPmStandardUserList()
        },
        leftInfo () {
            // if (this.leftInfo !== null && this.leftInfo !== undefined && this.leftInfo !== '') {
            this.findStageInfoById()
            // }
        },
        $route () {
            this.findStageInfoById()
            this.selectPmUserInfoManager()
            this.UerInfoPhotoFn()
            this.getCharacterList()
        }
    }
}
</script>
